package fsu.cs.cis5930;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.Spinner;

/**
 *  This is the activity that the user is first presented. It should contain the game logo, a way to
 *  start the game, and a way to specify the game settings.
 *
 */
public class MainActivity extends Activity {
	
	private ImageView logo;
	private ImageView single;
	private ImageView settings;
	private Context mContext;
	private MediaPlayer mp;
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        logo = (ImageView) findViewById(R.id.logo);
        single = (ImageView) findViewById(R.id.single);
        settings = (ImageView) findViewById(R.id.settings);
        mContext = this;
        
        Animation anim = new ScaleAnimation(1,0.7f,1f,0.7f,100,100 );
        anim.setRepeatCount(Animation.INFINITE);
        anim.setRepeatMode(Animation.REVERSE);
        anim.setDuration(400);
        logo.setAnimation(anim);
        
        Animation anim2 = new RotateAnimation(-1,1,50,0 );
        anim2.setRepeatCount(Animation.INFINITE);
        anim2.setRepeatMode(Animation.REVERSE);
        anim2.setDuration(100);
        single.setAnimation(anim2);
        settings.setAnimation(anim2);
        
        single.setOnClickListener( new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				stopSounds();
				startActivity(new Intent(mContext, GameActivity.class));
				
			}
		});
        
        settings.setOnClickListener( new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				startActivity(new Intent(mContext, SettingsActivity.class));
				
			}
		});
    }
    
    public void onStart()
    {
    	super.onStart();
    	 mp = MediaPlayer.create(this, R.raw.start);
         mp.start();
    	
    }
    
    public void onPause()
    {
    	super.onPause();
    	stopSounds();
    }
    
    void stopSounds()
    { mp.release();
       }
    
}